<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .warning{
            background: red;
        }

    </style>
</head>
<body>
    <div id="app"></div>
    <script src="react.js"></script>
    <script src="react-dom.js"></script>
    <script src="browser.min.js"></script>
    <script type="text/babel">
    function WarningBanner(props) {
        if(!props.warn){
            return null;
        }
        return(
            <div className="warning">Warning</div>
        );
    }
    class Page extends React.Component{
        constructor(props) {
            super(props)
            this.state = {showWarning:true}
            this.handleToggleClick = this.handleToggleClick.bind(this)
        }
        handleToggleClick(){
            this.setState(prevState=>({
                showWarning:!prevState.showWarning
            }))
        }
        render(){
            return(
                <div>
                <WarningBanner warn={this.state.showWarning} />
                <button onClick={this.handleToggleClick}>
                {this.state.showWarning ? "Hide" : "show"}
                </button>
                </div>
            );
        }
        
    }
    ReactDOM.render(
        <Page />,
        document.getElementById("app")
    )


    const numbers = [1, 2, 3, 4, 5];
    const doubled = numbers.map((number) => number * 2);
    console.log(doubled);
    console.log(numbers);
    </script>
</body>
</html>